<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="证件号" prop="cardNo">
        <el-input
          v-model="queryParams.cardNo"
          placeholder="请输入证件号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['dataCenter:patient:add']"
          >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['dataCenter:patient:edit']"
          >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['dataCenter:patient:remove']"
          >删除
        </el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['dataCenter:patient:export']"
          >导出
        </el-button>
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="patientList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="主键id" align="center" prop="id" /> -->
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="性别" align="center" prop="sex">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yy_sex_types" :value="scope.row.sex" />
        </template>
      </el-table-column>

      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="手机号" align="center" prop="phone" />
      <el-table-column label="证件号" align="center" prop="cardNo" />
      <!-- <el-table-column label="名字拼音" align="center" prop="namePinyin" /> -->
      <el-table-column label="病历号" align="center" prop="medicalRecordNo" />
      <!-- <el-table-column
        label="慢病ICD名"
        align="center"
        prop="chronicDiseaseCode"
      /> -->
      <el-table-column
        label="慢病名"
        align="center"
        prop="chronicDisease"
        width="250"
      />
      <!-- <el-table-column label="证件类型" align="center" prop="cardType">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_card_type"
            :value="scope.row.cardType"
          />
        </template>
      </el-table-column> -->

      <!-- <el-table-column label="出生日期" align="center" prop="birthday" /> -->
      <!-- <el-table-column label="国籍" align="center" prop="nationality">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_nationality_types"
            :value="scope.row.nationality"
          />
        </template>
      </el-table-column>
      <el-table-column label="婚姻状况" align="center" prop="maritalType">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_marital_status"
            :value="scope.row.maritalType"
          />
        </template>
      </el-table-column>
      <el-table-column label="文化程度" align="center" prop="educationType">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_education_background"
            :value="scope.row.educationType"
          />
        </template>
      </el-table-column>
      <el-table-column label="职业" align="center" prop="occupation">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_job_type"
            :value="scope.row.occupation"
          />
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="电子邮箱" align="center" prop="mail" /> -->
      <el-table-column label="常用地址" align="center" prop="address" />
      <el-table-column
        label="常用地址详细"
        align="center"
        prop="addressDetail"
      />
      <!-- <el-table-column label="联系关系" align="center" prop="contactsType">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_relation_type"
            :value="scope.row.contactsType"
          />
        </template>
      </el-table-column>
      <el-table-column label="联系人" align="center" prop="contacts" />
      <el-table-column
        label="联系电话"
        align="center"
        prop="contactsTelephone"
      />
      <el-table-column
        label="联系人地址"
        align="center"
        prop="contactsAddress"
      />
      <el-table-column
        label="联系人地址详细"
        align="center"
        prop="contactsAddressDetail"
      />
      <el-table-column label="民族" align="center" prop="nation" />
      <el-table-column label="医疗保险" align="center" prop="medicalInsurance">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_health_insurance"
            :value="scope.row.medicalInsurance"
          />
        </template>
      </el-table-column>
      <el-table-column label="宗教信仰" align="center" prop="religiousBeliefs">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_religion_types"
            :value="scope.row.religiousBeliefs"
          />
        </template>
      </el-table-column>
      <el-table-column label="工作单位" align="center" prop="workUnit" />
      <el-table-column label="工作单位地址" align="center" prop="workAddress" />
      <el-table-column
        label="工作单位地址详情"
        align="center"
        prop="workAddressDetail"
      />
      <el-table-column label="工作单位电话" align="center" prop="workPhone" />
      <el-table-column
        label="工作单位邮编"
        align="center"
        prop="workPostCode"
      />
      <el-table-column label="介绍人" align="center" prop="referee" />
      <el-table-column label="租户ID" align="center" prop="tenantId" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="创建人" align="center" prop="createId" />
      <el-table-column label="创建人名称" align="center" prop="createName" />
      <el-table-column label="修改人名称" align="center" prop="updateName" />
      <el-table-column label="医院名称" align="center" prop="hospitalName" />
      <el-table-column label="卡识别码" align="center" prop="cardSn" />
      <el-table-column label="社保卡号" align="center" prop="socialCardNo" />
      <el-table-column
        label="社保卡详细信息"
        align="center"
        prop="socialCardInfo"
      />
      <el-table-column label="跳过原因" align="center" prop="skinRemark" />
      <el-table-column label="参保信息" align="center" prop="insuinfo" />
      <el-table-column label="个人参保编码" align="center" prop="psnNo" />
      <el-table-column label="是否跳过" align="center" prop="isSkin" /> -->
      <el-table-column label="来源" align="center" prop="source">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.yy_source_types"
            :value="scope.row.source"
          />
        </template>
      </el-table-column>
      <!-- <el-table-column label="路线" align="center" prop="route" /> -->
      <el-table-column
        label="客服人员姓名"
        align="center"
        prop="customerName"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="lookDetails(scope.row)"
            v-hasPermi="['dataCenter:patient:edit']"
            >查看
          </el-button>
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['dataCenter:patient:edit']"
            >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['dataCenter:patient:remove']"
            >删除
          </el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改云HIS-患者档案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="名字拼音" prop="namePinyin">
          <el-input v-model="form.namePinyin" placeholder="请输入名字拼音" />
        </el-form-item>
        <el-form-item label="病历号" prop="medicalRecordNo">
          <el-input v-model="form.medicalRecordNo" placeholder="请输入病历号" />
        </el-form-item>
        <el-form-item label="慢病ICD名" prop="chronicDiseaseCode">
          <el-input
            v-model="form.chronicDiseaseCode"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="慢病名" prop="chronicDisease">
          <el-input
            v-model="form.chronicDisease"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="手机号" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="证件号" prop="cardNo">
          <el-input v-model="form.cardNo" placeholder="请输入证件号" />
        </el-form-item>
        <el-form-item label="证件类型" prop="cardType">
          <el-select v-model="form.cardType" placeholder="请选择证件类型">
            <el-option
              v-for="dict in dict.type.yy_card_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="性别" prop="sex">
          <el-select v-model="form.sex" placeholder="请选择性别">
            <el-option
              v-for="dict in dict.type.yy_sex_types"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="出生日期" prop="birthday">
          <el-input v-model="form.birthday" placeholder="请输入出生日期" />
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input v-model="form.age" placeholder="请输入年龄" />
        </el-form-item>
        <el-form-item label="国籍" prop="nationality">
          <el-select v-model="form.nationality" placeholder="请选择国籍">
            <el-option
              v-for="dict in dict.type.yy_nationality_types"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="婚姻状况" prop="maritalType">
          <el-select v-model="form.maritalType" placeholder="请选择婚姻状况">
            <el-option
              v-for="dict in dict.type.yy_marital_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="文化程度" prop="educationType">
          <el-select v-model="form.educationType" placeholder="请选择文化程度">
            <el-option
              v-for="dict in dict.type.yy_education_background"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="职业" prop="occupation">
          <el-select v-model="form.occupation" placeholder="请选择职业">
            <el-option
              v-for="dict in dict.type.yy_job_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="电子邮箱" prop="mail">
          <el-input v-model="form.mail" placeholder="请输入电子邮箱" />
        </el-form-item>
        <el-form-item label="常用地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入常用地址" />
        </el-form-item>
        <el-form-item label="常用地址详细" prop="addressDetail">
          <el-input
            v-model="form.addressDetail"
            placeholder="请输入常用地址详细"
          />
        </el-form-item>
        <el-form-item label="联系关系" prop="contactsType">
          <el-select v-model="form.contactsType" placeholder="请选择联系关系">
            <el-option
              v-for="dict in dict.type.yy_relation_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="联系人" prop="contacts">
          <el-input v-model="form.contacts" placeholder="请输入联系人" />
        </el-form-item>
        <el-form-item label="联系电话" prop="contactsTelephone">
          <el-input
            v-model="form.contactsTelephone"
            placeholder="请输入联系电话"
          />
        </el-form-item>
        <el-form-item label="联系人地址" prop="contactsAddress">
          <el-input
            v-model="form.contactsAddress"
            placeholder="请输入联系人地址"
          />
        </el-form-item>
        <el-form-item label="联系人地址详细" prop="contactsAddressDetail">
          <el-input
            v-model="form.contactsAddressDetail"
            placeholder="请输入联系人地址详细"
          />
        </el-form-item>
        <el-form-item label="民族" prop="nation">
          <el-input v-model="form.nation" placeholder="请输入民族" />
        </el-form-item>
        <el-form-item label="医疗保险" prop="medicalInsurance">
          <el-select
            v-model="form.medicalInsurance"
            placeholder="请选择医疗保险"
          >
            <el-option
              v-for="dict in dict.type.yy_health_insurance"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="宗教信仰" prop="religiousBeliefs">
          <el-select
            v-model="form.religiousBeliefs"
            placeholder="请选择宗教信仰"
          >
            <el-option
              v-for="dict in dict.type.yy_religion_types"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="工作单位" prop="workUnit">
          <el-input v-model="form.workUnit" placeholder="请输入工作单位" />
        </el-form-item>
        <el-form-item label="工作单位地址" prop="workAddress">
          <el-input
            v-model="form.workAddress"
            placeholder="请输入工作单位地址"
          />
        </el-form-item>
        <el-form-item label="工作单位地址详情" prop="workAddressDetail">
          <el-input
            v-model="form.workAddressDetail"
            placeholder="请输入工作单位地址详情"
          />
        </el-form-item>
        <el-form-item label="工作单位电话" prop="workPhone">
          <el-input v-model="form.workPhone" placeholder="请输入工作单位电话" />
        </el-form-item>
        <el-form-item label="工作单位邮编" prop="workPostCode">
          <el-input
            v-model="form.workPostCode"
            placeholder="请输入工作单位邮编"
          />
        </el-form-item>
        <el-form-item label="介绍人" prop="referee">
          <el-input v-model="form.referee" placeholder="请输入介绍人" />
        </el-form-item>
        <el-form-item label="租户ID" prop="tenantId">
          <el-input v-model="form.tenantId" placeholder="请输入租户ID" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="创建人" prop="createId">
          <el-input v-model="form.createId" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="创建人名称" prop="createName">
          <el-input v-model="form.createName" placeholder="请输入创建人名称" />
        </el-form-item>
        <el-form-item label="修改人名称" prop="updateName">
          <el-input v-model="form.updateName" placeholder="请输入修改人名称" />
        </el-form-item>
        <el-form-item label="医院名称" prop="hospitalName">
          <el-input v-model="form.hospitalName" placeholder="请输入医院名称" />
        </el-form-item>
        <el-form-item label="卡识别码" prop="cardSn">
          <el-input v-model="form.cardSn" placeholder="请输入卡识别码" />
        </el-form-item>
        <el-form-item label="社保卡号" prop="socialCardNo">
          <el-input v-model="form.socialCardNo" placeholder="请输入社保卡号" />
        </el-form-item>
        <el-form-item label="社保卡详细信息" prop="socialCardInfo">
          <el-input
            v-model="form.socialCardInfo"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="跳过原因" prop="skinRemark">
          <el-input
            v-model="form.skinRemark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="参保信息" prop="insuinfo">
          <el-input
            v-model="form.insuinfo"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="个人参保编码" prop="psnNo">
          <el-input v-model="form.psnNo" placeholder="请输入个人参保编码" />
        </el-form-item>
        <el-form-item label="是否跳过" prop="isSkin">
          <el-input v-model="form.isSkin" placeholder="请输入是否跳过" />
        </el-form-item>
        <el-form-item label="来源" prop="source">
          <el-select v-model="form.source" placeholder="请选择来源">
            <el-option
              v-for="dict in dict.type.yy_source_types"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="路线" prop="route">
          <el-input v-model="form.route" placeholder="请输入路线" />
        </el-form-item>
        <el-form-item label="客服人员姓名" prop="customerName">
          <el-input
            v-model="form.customerName"
            placeholder="请输入客服人员姓名"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 查看信息 -->
    <el-dialog
      title="患者档案"
      :visible.sync="reply"
      width="900px"
      append-to-body
    >
      <el-descriptions
        :column="3"
        labelStyle="width:110px;text-align:center;padding:6px;"
        contentStyle="min-width:130px;text-align:center;"
        v-if="userinfo"
        border
      >
        <el-descriptions-item label="姓名">{{
          userinfo.name
        }}</el-descriptions-item>
        <el-descriptions-item label="性别"
          ><dict-tag
            :options="dict.type.yy_sex_types"
            :value="userinfo.sex" /></el-descriptions-item
        ><el-descriptions-item label="年龄">{{
          userinfo.age
        }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{
          userinfo.phone
        }}</el-descriptions-item>
        <el-descriptions-item label="证件类型"
          ><dict-tag
            :options="dict.type.yy_card_type"
            :value="userinfo.cardType" /></el-descriptions-item
        ><el-descriptions-item label="证件号">{{
          userinfo.cardNo
        }}</el-descriptions-item> 
        <el-descriptions-item label="病历号">{{
          userinfo.medicalRecordNo
        }}</el-descriptions-item>
        <el-descriptions-item label="慢病名称">{{
          userinfo.chronicDisease
        }}</el-descriptions-item>
        <el-descriptions-item label="出生日期">{{
          userinfo.birthday
        }}</el-descriptions-item>
        <el-descriptions-item label="国籍"
          ><dict-tag
            :options="dict.type.yy_nationality_types"
            :value="userinfo.nationality"
        /></el-descriptions-item>
        <el-descriptions-item label="婚姻状况"
          ><dict-tag
            :options="dict.type.yy_marital_status"
            :value="userinfo.maritalType"
        /></el-descriptions-item>
        <el-descriptions-item label="文化程度"
          ><dict-tag
            :options="dict.type.yy_education_background"
            :value="userinfo.educationType"
        /></el-descriptions-item>
        <el-descriptions-item label="职业"
          ><dict-tag
            :options="dict.type.yy_job_type"
            :value="userinfo.occupation"
        /></el-descriptions-item>
        <el-descriptions-item label="电子邮箱">{{
          userinfo.mail
        }}</el-descriptions-item>
        <el-descriptions-item label="常用地址">{{
          userinfo.address
        }}</el-descriptions-item>
        <el-descriptions-item label="常用地址详细">{{
          userinfo.addressDetail
        }}</el-descriptions-item>
        <el-descriptions-item label="联系关系"
          ><dict-tag
            :options="dict.type.yy_relation_type"
            :value="userinfo.contactsType"
        /></el-descriptions-item>
        <el-descriptions-item label="联系人">{{
          userinfo.contacts
        }}</el-descriptions-item>
        <el-descriptions-item label="联系电话">{{
          userinfo.contactsTelephone
        }}</el-descriptions-item>
        <el-descriptions-item label="联系人地址">{{
          userinfo.contactsAddress
        }}</el-descriptions-item>
        <el-descriptions-item label="联系人地址详细">{{
          userinfo.contactsAddressDetail
        }}</el-descriptions-item>
        <el-descriptions-item label="民族"
          ><dict-tag
            :options="dict.type.yy_health_insurance"
            :value="userinfo.medicalInsurance"
        /></el-descriptions-item>
        <el-descriptions-item label="医疗保险"
          ><dict-tag
            :options="dict.type.yy_health_insurance"
            :value="userinfo.medicalInsurance"
        /></el-descriptions-item>
        <el-descriptions-item label="宗教信仰"
          ><dict-tag
            :options="dict.type.yy_religion_types"
            :value="userinfo.religiousBeliefs"
        /></el-descriptions-item>
        <el-descriptions-item label="工作单位">{{
          userinfo.workUnit
        }}</el-descriptions-item>
        <el-descriptions-item label="工作单位地址">{{
          userinfo.workAddress
        }}</el-descriptions-item>
        <el-descriptions-item label="工作单位地址详情">{{
          userinfo.workAddressDetail
        }}</el-descriptions-item>
        <el-descriptions-item label="工作单位电话">{{
          userinfo.workPhone
        }}</el-descriptions-item>
        <el-descriptions-item label="工作单位邮编">{{
          userinfo.workPostCode
        }}</el-descriptions-item>
        <el-descriptions-item label="介绍人">{{
          userinfo.referee
        }}</el-descriptions-item>
        <el-descriptions-item label="创建人名称">{{
          userinfo.createName
        }}</el-descriptions-item>
        <el-descriptions-item label="社保卡号">{{
          userinfo.socialCardNo
        }}</el-descriptions-item>
        <el-descriptions-item label="跳过原因">{{
          userinfo.skinRemark
        }}</el-descriptions-item>
        <el-descriptions-item label="来源"
          ><template slot-scope="scope">
            <dict-tag
              :options="dict.type.yy_source_types"
              :value="userinfo.source"
            /> </template
        ></el-descriptions-item>
        <el-descriptions-item label="路线">{{
          userinfo.route
        }}</el-descriptions-item>
        <el-descriptions-item label="客服人员姓名">{{
          userinfo.customerName
        }}</el-descriptions-item>
      </el-descriptions>
      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="submitForm">确 定</el-button> -->
        <el-button @click="reply = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPatient,
  getPatient,
  delPatient,
  addPatient,
  updatePatient,
} from "@/api/dataCenter/patient";

export default {
  name: "Patient",
  dicts: [
    "yy_nationality_types",
    "yy_relation_type",
    "yy_health_insurance",
    "yy_source_types",
    "yy_education_background",
    "yy_card_type",
    "yy_sex_types",
    "yy_religion_types",
    "yy_job_type",
    "yy_marital_status",
  ],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 云HIS-患者档案表格数据
      patientList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      reply: false,
      userinfo: null,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        phone: null,
        cardNo: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          {
            required: true,
            message: "姓名不能为空",
            trigger: "blur",
          },
        ],
        medicalRecordNo: [
          {
            required: true,
            message: "病历号不能为空",
            trigger: "blur",
          },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询云HIS-患者档案列表 */
    getList() {
      this.loading = true;
      listPatient(this.queryParams).then((response) => {
        this.patientList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        patientId: null,
        name: null,
        namePinyin: null,
        medicalRecordNo: null,
        chronicDiseaseCode: null,
        chronicDisease: null,
        phone: null,
        cardNo: null,
        cardType: null,
        sex: null,
        birthday: null,
        age: null,
        nationality: null,
        maritalType: null,
        educationType: null,
        occupation: null,
        mail: null,
        address: null,
        addressDetail: null,
        contactsType: null,
        contacts: null,
        contactsTelephone: null,
        contactsAddress: null,
        contactsAddressDetail: null,
        nation: null,
        medicalInsurance: null,
        religiousBeliefs: null,
        workUnit: null,
        workAddress: null,
        workAddressDetail: null,
        workPhone: null,
        workPostCode: null,
        referee: null,
        tenantId: null,
        remark: null,
        createTime: null,
        createId: null,
        createName: null,
        updateTime: null,
        updateId: null,
        updateName: null,
        hospitalName: null,
        cardSn: null,
        socialCardNo: null,
        socialCardInfo: null,
        skinRemark: null,
        insuinfo: null,
        psnNo: null,
        isSkin: null,
        source: null,
        route: null,
        customerId: null,
        customerName: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加云HIS-患者档案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getPatient(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改云HIS-患者档案";
      });
    },
    // 查看
    lookDetails(row) {
      const id = row.patientId || this.ids;
      getPatient(id).then((response) => {
        this.userinfo = response.data;
        this.reply = true;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          //   this.form.display = this.form.display.join(",");
          if (this.form.id != null) {
            updatePatient(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.reply = false;
              this.getList();
            });
          } else {
            addPatient(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm("是否确认删除该患者？")
        .then(function () {
          return delPatient(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "dataCenter/patient/export",
        {
          ...this.queryParams,
        },
        `patient_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
